// 路由切换时自动清除自身状态
import React, { useEffect } from 'react';

export default function withClearState(namespace) {
    return Component => props => {
        useEffect(() => () => {
            props.dispatch({
                type: `${namespace}/clear`
            });
        }, []);
        return <Component {...props} />;
    };
}
